import { Fresh, HMS2S, S2HMS, Timekeep, safarigetdate } from '@/utils/date.js'
import constants from './constant.js'
import { addZero } from '@/utils/_'
import { Copy } from '@/utils/object'
import { getuserUid, getUserLogin } from '@/utils/auth'
import { setRemind } from '@/utils/chat.js'
const defaultData = {
    // 状态1  下单constants分钟内  【可重选表现师阶段】
    // 状态2  下单超过constants分钟  【待服务之不可重选表现师阶段】
    // 状态3  下单后对方已签到 [带服务状态]
    status: -1,
    // 实例化后的timekeep
    timekeep: null,
    showTotalTime: '',
    // 设计师不同状态的变量
    status1time: '',
    state7time: Copy(constants.hms),
    state8time: Copy(constants.hms),
    state9time: Copy(constants.hms),
    state911time: Copy(constants.hms),
    state15Price: '',
    state17day: '',
    state9HPrice: '--',
    // 表现师不同状态的变量
    bstate: {
        time211: Copy(constants.hms),
        time3: Copy(constants.hms),
        time6: Copy(constants.hms),
        time7: Copy(constants.hms),
    },
    testData: '',
    testData2: '',
    isComplaint: false,
    未申述: false,
    已申述: false,
    detail: true,
    // 实例化后的计时器
    fresh: null,
}
let hmstoo = (totalTime) => {
    return {
        h: totalTime.split(':')[0],
        m: totalTime.split(':')[1],
        s: totalTime.split(':')[2],
    }
}
export const _defaultData = defaultData
export const _methods = {
    handleData(){
        this.status = -1
        // console.log('处理order item')
        // console.log(this.form.orderName, this.form)
        let createDate = this.form.createDate
        let doneDate = this.form.doneDate || 0
        let gapDate = +new Date() - +safarigetdate(createDate)
        let gapDoneDate = +new Date() - +safarigetdate(doneDate)
        console.log('gapDate')
        console.log(gapDate)
        // if(localStorage.MOCK){
        //     gapDate = +new Date() - +new Date((createDate))
        // }
        const orderInfo = JSON.parse(JSON.stringify(this.form))
        // 相差值
        let timeM = gapDate / 1e3 / 60
        // 完成时间（分）
        let orderDoneTimeM = doneDate === 0 ? 0 : gapDoneDate / 1e3 / 60
        this.timekeep = new Timekeep()
        let taskId = this.timekeep.getTaskId()
        let gapHomeTimems = (+new Date(safarigetdate(orderInfo.homeTime)) - +new Date())
        let gapHomeTime = gapHomeTimems / 1e3 / 60
        console.log('gapHomeTimems')
        console.log(gapHomeTimems)
        if(!this.fresh){
            this.fresh = new Fresh()
        }
        let fresh = this.fresh
        this.isComplaint = orderInfo.complaintUid !== null
        this.未申述 = orderInfo.appealStatus === null
        this.已申述 = orderInfo.appealStatus !== null

        // 缺天
        this.showTotalTime = orderInfo.totalTime.replace(':', '小时').replace(':', '分钟').replace(':', '秒') + '秒'
        // 测试数据
        this.testData = orderInfo
        // 设计师
        if (this.type == '1') {
            // 状态1  下单constants分钟内  【可重选表现师阶段】【待服务状态】 
            // if (orderInfo.orderStatus === 1 && timeM <= constants.countdownTime && orderInfo.registerStatus === 2) {
            if (orderInfo.status === 1) {
                this.status = 1
                // let fresh = new Fresh()
                fresh.add(
                    +new Date() + ((constants.countdownTime * 1e3 * 60) - gapDate),
                    time => {
                        this.status1time = time.val
                        if (!time.state) {
                            // this.status = 2
                            this.$emit('updateOrder')
                        }
                    },
                    (({ d, h, m, s }) => `${addZero(m, 2)}:${addZero(s, 2)}`)
                )
                // fresh.start()
            }
            // 状态2  下单超过constants分钟  【待服务之不可重选表现师阶段】【待服务状态】
            // if (orderInfo.orderStatus === 1 && timeM > constants.countdownTime && orderInfo.registerStatus === 2) {
            if (orderInfo.status === 2) {
                this.status = 2
            }
            // 状态3  下单后对方已签到 [待服务状态]
            // if (orderInfo.orderStatus === 1 && orderInfo.registerStatus === 1) {
            // if (orderInfo.status === 3) {
            if (orderInfo.status === 4) {
                this.status = 3
            }
            // 状态4  下单后对方已迟到 [待服务状态]
            // if (orderInfo.orderStatus === 1 && orderInfo.registerStatus === 3) {
            if (orderInfo.status === 3) {
                this.status = 4
            }
            // 状态5  下单后设计师取消订单 [待服务状态 -> 关闭状态] // TODO 这又6还有其他状态
            if (orderInfo.orderStatus === 6) {
                this.status = 5
            }
            // 状态6  下单后设计师取消订单 [待服务状态]  同意开启计时
            if (orderInfo.orderStatus === 1 && orderInfo.chronographStatus === 1) {
                this.status = 6
            }
            // TODO 转跳到计时详情
            // 状态7  进行中 计时 查看计时详情 
            if (orderInfo.orderStatus === 2 && orderInfo.chronographStatus === 2) {
                this.status = 7
                this.state7time = hmstoo(orderInfo.totalTime)
                this.timekeep.start(e => {
                    this.state7time = e
                }, {
                        n: HMS2S(orderInfo.totalTime, ':'),
                        // taskId
                    })
            }
            //  TODO 转跳到计时详情
            // 状态8 进行中  暂停 
            if (orderInfo.orderStatus === 2 && orderInfo.chronographStatus === 3) {
                this.status = 8
                this.state8time = {
                    h: orderInfo.totalTime.split(':')[0],
                    m: orderInfo.totalTime.split(':')[1],
                    s: orderInfo.totalTime.split(':')[2],
                }
            }
            // // 状态9 进行中 超过时间  
            // orderInfo.totalTime > (作图数量 * 6)
            // 此状态不要移动位置, 确保再前面的进行状态下执行
            if (orderInfo.orderStatus === 2 && orderInfo.chronographStatus === 2 && HMS2S(orderInfo.totalTime, ':') > (orderInfo.countUid * 6 * 60 * 60)) {
                this.status = 9
                this.state9time = hmstoo(orderInfo.totalTime)
                this.timekeep.start(e => {
                    this.state9time = e
                }, {
                        n: HMS2S(orderInfo.totalTime, ':'),
                        // taskId
                    })
                this.state9HPrice = orderInfo.gtTimePrice
            }
            // 状态911
            if (orderInfo.orderStatus === 2 && orderInfo.chronographStatus === 3 && HMS2S(orderInfo.totalTime, ':') > (orderInfo.countUid * 6 * 60 * 60)) {
                this.status = 911
                this.state911time = {
                    h: orderInfo.totalTime.split(':')[0],
                    m: orderInfo.totalTime.split(':')[1],
                    s: orderInfo.totalTime.split(':')[2],
                }
                this.state9HPrice = orderInfo.gtTimePrice
            }
            // 状态10 待收图    // 已完成(待上传图片)  可能存在其他问题   // TODO 再来一单的接口未对接   
            if (orderInfo.orderStatus === 3) {
                this.status = 10
            }
            // 状态11 待收图    (表现师已上传)
            if (orderInfo.orderStatus === 4) {
                this.status = 11
            }
            // 状态12 已完成   [再来一单 | 评价]    (已收图, 已结算)
            if (orderInfo.orderStatus === 5 && !Boolean(orderInfo.reviewUid)) {
                this.status = 12
            }
            // 状态122 
            if (orderInfo.orderStatus === 5 && !Boolean(orderInfo.reviewUid) && orderDoneTimeM >= 30) {
                this.status = 13
            }
            // 状态13 已完成   [请求改图 | 追评]    完成并且已评论   改动成->   [请求改图|查看详情]
            if (orderInfo.orderStatus === 5 && Boolean(orderInfo.reviewUid)) {
                this.status = 13
            }

            // 以下不确定
            // 已退款成功（有退款记录）
            // 状态14 已关闭 【投诉成功】 [投诉成功，平台已退款 | 查看详情]      complaintUid 有值是投诉成功
            // orderInfo.orderStatus === 6
            // if(orderInfo.orderType === 1 && Boolean(orderInfo.complaintUid) && 已退款){
            //     this.status = 14
            // }
            // 状态15 待改图 【改图师到位】 [改图师到位，付款改图 | 需支付 ¥1,500]  
            // if (orderInfo.orderType === 2 && orderInfo.orderStatus === 1 && orderInfo.subsistPayStatus === 0) {
            if (orderInfo.status === 15) {
                this.status = 15
                // 金额预付款 
                this.state15Price = orderInfo.subsist
            }
            // 状态16  进行中  【改图进行中】【改图师暂未上传】 [改图师暂未上传|催一催]
            if (orderInfo.orderType === 2 && orderInfo.orderStatus === 2 && orderInfo.subsistPayStatus === 1) {
                this.status = 16
            }
            // 状态17  待确认   [图已上传，1天自动确认|确认收图]
            if (orderInfo.orderType === 2 && orderInfo.orderStatus === 4) {
                this.status = 17
                this.state17day = 1 // 还剩几天自动收图
            }
            // 状态18  已完成 （改图已完成，不同上面）   [请求改图|评论]
            if (orderInfo.orderType === 2 && orderInfo.orderStatus === 5) {
                this.status = 18
            }


            // console.log('----this.status---')
            // console.log(this.status)
            // console.log('orderInfo.orderStatus')
            // console.log(orderInfo.orderStatus)
            // console.log((orderInfo.countUid * 6 * 60 * 60))
            // console.log(HMS2S(orderInfo.totalTime, ':'))
        }
        // 表现师
        if (this.type == '2') {
            let setClockStatus = () => {
                if (orderInfo.status === 2 && gapHomeTime > 0 && gapHomeTime >= constants.countdownTime) {
                    // if (orderInfo.status === 2 && gapHomeTime < constants.countdownTime) {
                    this.status = 2
                    setTimeout(() => {
                        this.$emit('updateOrder')
                    }, gapHomeTime * 60 * 1e3)
                }
                // console.log('----211---')
                // console.log(orderInfo.status, gapHomeTime, constants.countdownTime)
                if (orderInfo.status === 211 && gapHomeTime > 0 && gapHomeTime < constants.countdownTime) {
                // if (orderInfo.status === 2 && gapHomeTime > 0 && gapHomeTime < constants.countdownTime) {
                    // if (orderInfo.status === 2 && gapHomeTime >= constants.countdownTime) {
                    this.status = 211
                    fresh.add(
                        +new Date() + gapHomeTimems,
                        time => {
                            this.bstate.time211 = time.val
                            if (!time.state) {
                                // 更新数据
                                this.$emit('updateOrder')
                            }
                        },
                        (({ d, h, m, s }) => ({
                            h: addZero(h, 2),
                            m: addZero(m, 2),
                            s: addZero(s, 2)
                        }))
                    )
                }
            }
            this.status = -1
            if (orderInfo.status === 1) {
                this.status = 1
                fresh.add(
                    +new Date() + ((constants.countdownTime * 1e3 * 60) - gapDate),
                    time => {
                        this.status1time = time.val
                        if (!time.state) {
                            setClockStatus()
                            this.$emit('updateOrder')
                        }
                    },
                    (({ d, h, m, s }) => `${addZero(m, 2)}:${addZero(s, 2)}`)
                )
            }
            if (orderInfo.status === 13) {
                // console.log(orderInfo.orderName, JSON.parse(JSON.stringify(orderInfo)))
                this.status = 13
            }
            // 执行计时状态判断
            setClockStatus()
            // 后台说没法获取这个状态，好吧QAQ 
            // if (orderInfo.status === 3) {
            if (orderInfo.status === 3 && gapHomeTime < 0) {
                this.status = 3
                this.bstate.time3 = S2HMS(-(gapHomeTimems) / 1e3)
                this.timekeep.start(e => {
                    this.bstate.time3 = {
                        h: addZero(e.h | 0, 2),
                        m: addZero(e.m | 0, 2),
                        s: addZero(e.s | 0, 2),
                    }
                }, {
                        n: -(gapHomeTimems) / 1e3,
                        // taskId
                    })
            }
            if (orderInfo.status === 4) {
                this.status = 4
            }
            // 待对方确认
            // TODO 这个可能要刷新页面，或者定时更新，或者用ws（长链接）
            if (orderInfo.status === 5) {
                this.status = 5
            }
            // 计时中 计时中
            if (orderInfo.status === 6) {
                this.status = 6
                this.bstate.time6 = hmstoo(orderInfo.totalTime)
                this.timekeep.start(e => {
                    this.bstate.time6 = e
                }, {
                        n: HMS2S(orderInfo.totalTime, ':'),
                        // taskId
                    })
            }
            // 计时中 暂停中
            if (orderInfo.status === 7) {
                this.status = 7
                this.bstate.time7 = {
                    h: orderInfo.totalTime.split(':')[0],
                    m: orderInfo.totalTime.split(':')[1],
                    s: orderInfo.totalTime.split(':')[2],
                }
            }
            // 计时中 计时结束【待收图】
            if (orderInfo.status === 8) {
                this.status = 8
            }
            // 对方未结算收图 【待结算】【提醒Ta】
            if (orderInfo.status === 9) {
                this.status = 9
            }
            // 已结算,未评价   【查看评价】 不可点
            if (orderInfo.status === 10) {
                this.status = 10
            }
            // 已结算,已评价  【对方给出了评价|查看评价】
            if (orderInfo.status === 11) {
                this.status = 11
            }
            // 【对方对你进行了投诉|查看并申诉】 
            if (orderInfo.status === 12) {
                this.status = 12
            }
            // 已关闭,申诉处理中    
            if (orderInfo.status === 16) {
                this.status = 16
            }
            // 已关闭,申诉成功        【申诉成功|查看详情】
            if (orderInfo.status === 14) {
                this.status = 14
            }
            // 【申诉成功|查看详情】   （尾款金额： 图未完成，不结算） 
            if (orderInfo.status === 141) {
                this.status = 141
            }
            // 【申诉成功|查看详情】   （尾款金额：对方未收图结算） 
            if (orderInfo.status === 142) {
                this.status = 142
            }
            // 已关闭,申诉失败  【申诉失败|查看处理详情】
            if (orderInfo.status === 15) {
                this.status = 15
            }
            // if(orderInfo.status === 1){
            //     this.status = 11
            // }
            // // 开始倒计时
            // fresh.start()
        }
        if (this.type == '3') {
            this.status = -1
            // 待付款,待对方确认付款  【待对方确认付款|提醒Ta】
            if (orderInfo.status === 1) {
                this.status = 1
            }
            // // 进行中,改图还未完成 
            // if(orderInfo.status === 2){
            //     this.status = 2
            // }
            // 进行重,改图完成    【对方已付款，改图完成需上传|查看上传方法】
            if (orderInfo.status === 2 || orderInfo.status === 3) {
                this.status = 3
            }
            // 待确认,图已上传,待对方确认   【提醒Ta】
            if (orderInfo.status === 4) {
                this.status = 4
            }
            // :已完成,未评价    【待对方评价|查看评价】
            if (orderInfo.status === 5) {
                this.status = 5
            }
            // :已完成,未评价    【已评价|查看评价】
            if (orderInfo.status === 6) {
                this.status = 6
            }
        }
        // 开始倒计时
        fresh.start()
    },
    open_popup() {
        this.$emit('open_popup')
    },
	//请求改时要调一下后端的接口，某新要求的
	modifTimer(groupUid){
		HTTP('msg_modifTimer',{
			userUid:getuserUid(),
			groupUid:groupUid
		})
		.then(res=>{
			console.log(res);
		})
	},
    //提醒请求改时，结算，付款，确认，改图
    remind(content, groupUid, type) {
        this.$dialog.confirm({
            message: `是否确定${content}`
        }).then(async () => {
			if(type == 'remindModif'){
				this.modifTimer(groupUid);
			}
            if(content === '提醒结算收图' || content === '提醒上传图片' || content === '请求改时'){
                let status = content === '提醒结算收图' ? 2 : 
                            content === '提醒上传图片' ? 1 : 
                            content === '请求改时' ? 3 :
                            0
                let params = {
                    type: status,
                    orderUid: this.form.uid,
                }
                HTTP('app/buser/addSysMessage', params).then(e => {
                    if(e.code !== 200){
                        console.log('异常', e)
                        return
                    }
                })
            }
            let extObj = { 
				type, 
				name: getUserLogin().userName ,
				time:Date.parse(new Date())
			};
            let ext = JSON.stringify(extObj);
            let res = await HTTP("chat_send_msg", {
                content,
                userUid: getuserUid(),
                groupUid,
                ext,
                roomType: "group"
            });

            if (res.code == 200) {
                this.$toast(`提醒成功！`)
            } else {
                this.$toast(res.msg || '服务器异常')
                return
            }
            // let responseData = await HTTP('orderManagement/cancelOrder', params)
            // if(responseData.code !== 200){
            //     this.$toast( responseData.msg|| '服务器异常')
            //     return
            // }
            setTimeout(() => {
                this.$emit('updateOrder')
            }, 500)
        }).catch((e) => {
            console.log('cancel')
            console.log(e)
        })
    },
    //查看退款
    catRefund(refundmoney) {
        this.$dialog.alert({
            message:
                `退款金额(￥${refundmoney})在1至2天内会退回支付账户,如已收到，请忽略`
        });
    },
    //评价
    go_appraise(row, type) {
        // console.log(buserUid)
        // this.$router.push({ name: "designer-appraise", params: { uid, buserUid } })
        this.$router.push({
            path: "/designer/appraise", query: {
                uid: row.uid,
                buserUid: type === 'b' ? row.buserUid : row.guserUid
            }
        })
    },
    cacleOrder(orderUid) {
        this.$dialog.confirm({
            message: '是否确定取消订单'
        }).then(async () => {
            let params = {
                orderUid,
                updateBy: getuserUid()
            }
            let responseData = await HTTP('orderManagement/cancelOrder', params)
            if (responseData.code !== 200) {
                this.$toast(responseData.msg || '服务器异常')
                return
            }
            this.$emit('updateOrder')
        }).catch((e) => {
            console.log('cancel')
            console.log(e)
        })
    },
    timeStart(orderUid) {
        this.$dialog.confirm({
            message: '是否确定开启计时'
        }).then(async () => {
            let params = {
                userUid: getuserUid(),
                orderUid
            }
            let responseData = await HTTP('app/buser/timeStart', params)
            if (responseData.code !== 200) {
                this.$toast(responseData.msg || '服务器异常')
                return
            }
            //环信消息通知
            let extObj = {type: 'timerAgree',name: getUserLogin().userName };
            let ext = JSON.stringify(extObj);
            let content = "同意请求开启计时"
            let res = await HTTP("chat_send_msg", {
                content,
                userUid: getuserUid(),
                groupUid:this.form.groupUid,
                ext,
                roomType: "group"
            });
            if(res.code!=200){
                this.$toast(res.msg || '服务器异常')
                return
            }
            this.$emit('updateOrder')
        }).catch((e) => {
            console.log('cancel')
            console.log(e)
        })
    },
    reOrder(userUid) {
        this.$router.push('/performance/personal_details?buserid=' + userUid)
    },
    // 确认收图
    async successPay() {
        if(this.form.subsequentAmount !== null && this.form.subsequentAmount <= 0){
            let payResponse
            try {
                payResponse = await HTTP("order/updateOrdersStatus", {
                    userUid: getuserUid(),
                    orderUid: this.form.uid,
                })
                if(payResponse.code !== 200){
                    this.$toast(payResponse.msg || '服务器异常')
                    return
                }
                this.$toast('收图成功')
                setTimeout(() => {
                    this.$emit('updateOrder')
                }, 500)
            } catch (error) {
                this.$toast('服务器开小差了')
            }
            return
        }
        this.$emit('successPay', Copy(this.form), 'getImage')
    },
    // 结算收图 【改图后的收图】
    async changePay() {
        if(this.form.subsequentAmount !== null && this.form.subsequentAmount <= 0){
            let payResponse
            try {
                payResponse = await HTTP("order/updateOrdersStatus", {
                    userUid: getuserUid(),
                    orderUid: this.form.uid,
                })
                if(payResponse.code !== 200){
                    this.$toast(payResponse.msg || '服务器异常')
                    return
                }
                this.$toast('收图成功')
                setTimeout(() => {
                    this.$emit('updateOrder')
                }, 500)
            } catch (error) {
                this.$toast('服务器开小差了')
            }
            return
        }
        this.$emit('changePay', Copy(this.form), 'getImage')
    },
    onTimekeep() {
        this.$router.push(`/timekeep?uid=${this.form.uid}&buseruid=${this.form.userUid}`)
    },
    testFunc() {
        this.$emit('updateOrder')
    },
    // ----------表现师部分-------
    // 查看计时详情
    onCatTimekeep() {
        this.$router.push(`/designer/timekeep?uid=${this.form.uid}&buseruid=${this.form.userUid}`)
    },
    // 请求计时
    requestTimeKeep() {
        this.$dialog.confirm({
            message: '是否确定请求开启计时'
        }).then(async () => {
            let params = {
                bUserUid: getuserUid(),
                orderUid: this.form.uid
            }
            let responseData = await HTTP('app/buser/startTimeRequest', params)
            if (responseData.code !== 200) {
                this.$toast(responseData.msg || '服务器异常')
                return
            }
            //环信消息通知
            let extObj = {type: 'timerStart',name: getUserLogin().userName };
            let ext = JSON.stringify(extObj);
            let content = "请求开启计时"
            let res = await HTTP("chat_send_msg", {
                content,
                userUid: getuserUid(),
                groupUid:this.form.groupUid,
                ext,
                roomType: "group"
            });
            if(res.code!=200){
                this.$toast(res.msg || '服务器异常')
                return
            }
            // 也可以直接修改本地状态
            this.$emit('updateOrder')
            // setTimeout(() => {
            //     this.$emit('updateOrder')
            // }, 500)
            // setTimeout(() => {
            //     this.$emit('updateOrder')
            // }, 1e3)
        }).catch((e) => {
            console.log('cancel')
            console.log(e)
        })
    },
    // 前往签到
    onClockIn() {
        this.$router.push(`/clockin?orderUid=${this.form.uid}`)
    },
    // 查看上次方法
    catUploadMethod() {
        this.$dialog.alert({
            message:
                "请登录图小助官方网站，进入“表现师后台管理”模块，输入表现师的账号和密码即可上传作品；官网地址为：www.tuxiaozhu.com"
        });
        // console.log('查看上传方法')
    },
    // 提醒他
    // remind() {
    //     console.log('提醒Ta')
    // },
    // 查看评价
    catAssess(row) {
        this.$router.push({ path: "/performance/assessDetail", query: { uid: row.uid } })
    },
    //查看并申诉
    catReview(uid, orderName) {
        this.$router.push({ name: "performance-complaintDetail", params: { uid, orderName } })
        this.detail=false
    },
    // 查看详情
    catDetail(uid, iconUrl) {
        // if(getUserLogin().role==1){
        //     this.$router.push({ name: "designer-orderDetail", params: { uid } })
        // }else{
        //     this.$router.push({ name: "performance-subsidy", params: { uid } })
        // }
        if(this.detail){
            if (this.type == 1) {
                this.$store.commit("setorderUid", uid)
                this.$store.commit("seticonUrl", iconUrl)
                this.$router.push("/designer/orderDetail")
    
            } else {
                this.$store.commit("setorderUid", uid)
                this.$store.commit("seticonUrl", iconUrl)
                this.$router.push("/performance/subsidy")
            }
            console.log('查看详情')
        }
        
        
    },
    //跳转聊天室
    go_chat(id, orderId) {
        if(this.groupUids){
            this.groupUids.includes(id) && this.groupUids.splice(this.groupUids.findIndex(gid => gid == id), 1);
			this.clearHot(id);
        }
        setRemind(this.groupUids)
        this.$router.push({
            path: "/performance/chat", query: {
                id, orderId
            }
        })
    },
	//清除红点
	clearHot:function(id){
		let hots = JSON.parse(window.localStorage.getItem("unread"));
		//去除未读消息数
		if(hots){
			hots.map((o,n)=>{
				if(o.id == id){
					hots.splice(n,1);
				}
			})
			//写入缓存
			window.localStorage.setItem("unread", JSON.stringify(hots));
		}
	},
    // 改图支付
    updateImagePay() {
        this.$emit('successPay', Copy(this.form), 'changeImagePay')
        // this.$emit('successPay', Copy(this.form), 'getImage')

    },
    // 改图师确认收图
    async successGetImage() {
        let params = {
            orderUid: this.form.uid,
            userUid: getuserUid(),
        }
        let response
        try {
            response = await HTTP("order/updateOrdersStatus", params)
            if (response.code !== 200) {
                this.$toast(response.msg || '收图异常')
                return
            }
            this.$toast('收图成功')
            this.$emit('updateOrder')
        } catch (error) {
            this.$toast('服务器开小差了')
            console.log(error)
        }
    }

}
export function _destroyed() {
    // 释放所有计时资源
    this.timekeep && this.timekeep.end()
    this.fresh && this.fresh.end()
    this.data = Copy(defaultData)
}
export const main = {
    props: ["form", "type", "groupUids"],
    data() {
        return Copy(defaultData)

    },
    watch: {
        status(v){
            // console.log('status')
        },
        form(v){
            console.log('更新')
            this.form = v
            _destroyed.bind(this)()
            this.handleData()
        }
    },
    created() {
        // console.log(this.groupUids)
        // console.log(12345678)
        // console.log(this.type)
        // 初始化数据
        // this.form = {"orderType":1,"endDate":null,"appealStatus":null,"homeTime":"2019-07-13 11:00:00","orderStatus":1,"bonusContent":null,"refundmoney":null,"buserUid":"d890d51a06674e88aa8b3af81b4e4c52",
        // "uid":"c46f4bde67384024a00f7dcb8b3a6960",
        // "deductionUid":null,"countUid":1,"suserUid":"466343161e7a46bfbf309095a22de0dd","bonusMoney":null,"complaintStatus":null,"chronographStatus":null,"gtTimePrice":60,"reformerName":null,"subsist":0.01,"complaintUid":null,
        // "orderName":"初九视频2",
        // "createDate":"2019-07-09 21:30:20","address":"广东深圳市南山区54456" + Math.random(),"subsequentAmountPayStatus":null,"totalTime":"00:00:00","subsistPayStatus":1,"processResult":null,"userName":"表现师11号","guserUid":null,"countTime":null,"preordainDate":["2019-07-13"],"beginDate":null,"subsequentAmount":null,"refundstatus":null,"name":"360全景图-异型模型","registerStatus":null,"reviewUid":null,"userUid":"d890d51a06674e88aa8b3af81b4e4c52","groupUid":"87324847308801","status":1}

        this.handleData()
        // setTimeout(() => {
        //     this.form = {"orderType":1,"endDate":null,"appealStatus":null,"homeTime":"2019-07-19 11:00:00","orderStatus":1,"bonusContent":null,"refundmoney":null,"buserUid":"d890d51a06674e88aa8b3af81b4e4c52","uid":"4e06317f6b47443da451a61c1828e8b1","deductionUid":null,"countUid":1,"suserUid":"466343161e7a46bfbf309095a22de0dd","bonusMoney":null,"complaintStatus":null,"chronographStatus":null,"gtTimePrice":60,"reformerName":null,"subsist":0.01,"complaintUid":null,"orderName":"初九可视化","createDate":"2019-07-09 21:36:48","address":"广东深圳市福田区uyyy","subsequentAmountPayStatus":null,"totalTime":"00:00:00","subsistPayStatus":1,"processResult":null,"userName":"表现师11号","guserUid":null,"countTime":null,"preordainDate":["2019-07-19"],"beginDate":null,"subsequentAmount":null,"refundstatus":null,"name":"普通效果图-普通模型","registerStatus":null,"reviewUid":null,"userUid":"d890d51a06674e88aa8b3af81b4e4c52","groupUid":"87326478893057","status":1}
        //     _destroyed.bind(this)()
        // // this.form = {"orderType":1,"endDate":null,"appealStatus":null,"homeTime":"2019-07-14 09:00:00","orderStatus":1,"bonusContent":null,"refundmoney":null,"buserUid":"d890d51a06674e88aa8b3af81b4e4c52",
        // // // "uid":"dce56410bdf04883bdd9d45df485c2a54",
        // // "uid":"c46f4bde67384024a00f7dcb8b3a6960",
        // // "deductionUid":null,"countUid":1,"suserUid":"466343161e7a46bfbf309095a22de0dd","bonusMoney":null,"complaintStatus":null,"chronographStatus":null,"gtTimePrice":60,"reformerName":null,"subsist":0.01,"complaintUid":null,"orderName":"初九背单词","createDate":"2019-07-09 21:30:26","address":"广东深圳市南山区A123456","subsequentAmountPayStatus":null,"totalTime":"00:00:00","subsistPayStatus":1,"processResult":null,"userName":"表现师11号","guserUid":null,"countTime":null,"preordainDate":["2019-07-14"],"beginDate":null,"subsequentAmount":null,"refundstatus":null,"name":"普通效果图-普通模型","registerStatus":null,"reviewUid":null,"userUid":"d890d51a06674e88aa8b3af81b4e4c52","groupUid":"87326085677057","status":1}
        //     this.handleData()
        // }, 3e3)
    },
    methods: _methods,
    destroyed: _destroyed,
}